/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa036.kiss.Entity;

/**
 *
 * @author Vasa
 */
public class SluzbaKolejeDTO {
    
    private Long id;
    private KolejDTO kolej;
    private String nazev;
    private Double cena;
    private String kontaktni_informace;

  public Long getId () {

    return this.id;
  }

  public SluzbaKolejeDTO setId ( final Long id ) {

    if ( id != null ) {

      this.id = new Long ( id.longValue () );
    }

    return this;
  }

    public Double getCena() {
        return cena;
    }

    public void setCena(Double cena) {
        this.cena = cena;
    }

    public KolejDTO getKolej() {
        return kolej;
    }

    public void setKolej(KolejDTO kolej) {
        this.kolej = kolej;
    }

    public String getNazev() {
        return nazev;
    }

    public void setNazev(String nazev) {
        this.nazev = nazev;
    }

    public String getKontaktni_informace() {
        return kontaktni_informace;
    }

    public void setKontaktni_informace(String kontaktni_informace) {
        this.kontaktni_informace = kontaktni_informace;
    }
  

  @Override
  public boolean equals ( final Object rhs ) {

    if ( this == rhs ) return true;

    if ( rhs == null ) return false;

    if ( this.getClass () != rhs.getClass () ) return false;

    SluzbaKolejeDTO c = (SluzbaKolejeDTO) rhs;

    return this.id == null ? c.id == null : this.id.equals ( c.id ) &&
        this.kolej == null ? c.kolej == null : this.kolej.equals ( c.kolej ) &&
        this.nazev == null ? c.nazev == null : this.nazev.equals ( c.nazev ) &&
        this.cena == null ? c.cena == null : this.cena.equals ( c.cena ) &&
        this.kontaktni_informace == null ? c.kontaktni_informace == null : this.kontaktni_informace.equals ( c.kontaktni_informace );
  }

  @Override
  public int hashCode () {

    final int[] hashCodes = {
        (this.id == null) ? 0 : this.id.hashCode (),
        (this.kolej == null) ? 0 : this.kolej.hashCode (),
        (this.nazev == null) ? 0 : this.nazev.hashCode (),
        (this.cena == null) ? 0 : this.cena.hashCode (),
        (this.kontaktni_informace == null) ? 0 : this.kontaktni_informace.hashCode ()
    };

    int hash = 17;
    for ( final int currentHashCode: hashCodes ) {

      hash = hash * 31 + currentHashCode;
    }

    return hash;
  }

  @Override
  public Object clone () {

    try {

      return ( (SluzbaKolejeDTO) super.clone () ).setId ( this.id );
    } catch ( CloneNotSupportedException ex ) {

      assert false: "CloneNotSupportedException thrown";
      return null;
    }
  }

  @Override
  public String toString () {

    return this.id + ": " + this.nazev + " je za "  + this.cena.toString()
        + " vice zde " + this.kontaktni_informace
    ;
  }

  /**
   * Determine whether the person has set necessary information
   */
  public void checkState () {

    final boolean noNazev = this.nazev == null || this.nazev.isEmpty ();
    final boolean noCena = this.cena == null;

    if ( noNazev && noCena )  {

      throw new IllegalStateException ( "Nazev a cena musi byt nastaveny" );
    }
  }
}
